package finalproject.model.rooms;

import finalproject.config.Randomizer;
import finalproject.model.items.CheatSheet;
import finalproject.model.player.Player;
import finalproject.view.StringManager;

/**
 * A class representing a corridor
 * @author Yassine Tijani
 *
 */
public class Corridor extends Room {
    
	/**
	 * the sheet in case the corridor contain it
	 */
    private CheatSheet sheet;

    /**
     * @param description The corridor description
     * @param isLighted if the corridor is lighted or not
     */
    public Corridor(String description,boolean isLighted) {
        super(description,isLighted);
    }

 

    @Override
    public boolean doActivity(Player p) {
        if(sheet != null)
        {
            p.getItemHolder().addItem(sheet);
            return true;
        }
        else
        {
        return false;
        }
    }



    @Override
    public boolean prepareActivity(Player p) {
        if(Randomizer.getRandom().nextInt(9) == 1)
        {
            this.sheet = CheatSheet.getInstance();
            return true;
        }
        else
        {
            this.sheet = null;
            return false;
        }
    }

    @Override
	public String toString()
    {
        if(!isLighted())
        {
            return super.toString() + " : " + StringManager.getString("nolight");
        }
        else
        {
            return super.toString() + " : " + StringManager.getString("withlight");
        }
    }


}
